package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {
    /**
     * 根据菜品分类id查询套餐数量
     * @param id
     * @return
     */
    @Select("select * from setmeal where category_id = #{id};")
    Integer countByCategoryId(Long id);

    /**
     * 套餐分页查询
     * @param setmealPageQueryDTO
     * @return
     */
    Page<Setmeal> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);


    @AutoFill(OperationType.INSERT)
    Long insert(Setmeal setmeal);

    /**
     * 通过id获取套餐信息
     * @param id
     * @return
     */
    @Select("select * from setmeal where id = #{id};")
    Setmeal getById(Long id);

    /**
     * 修改套餐数据
     * @param setmeal
     */
    @AutoFill(OperationType.UPDATE)
    void update(Setmeal setmeal);

    /**
     * 通过id集合获取套餐
     * @param ids
     * @return
     */
    List<Setmeal> getByIds(List<Long> ids);

    /**
     * 通过id集合删除套餐
     * @param ids
     */
    void deleteByIds(List<Long> ids);
}
